package com.miyake.loveviewweb.server.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2012-07-11 14:41:10")
/** */
public final class DataModelMeta extends org.slim3.datastore.ModelMeta<com.miyake.loveviewweb.shared.model.DataModel> {

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Integer> chartColumns = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Integer>(this, "chartColumns", "chartColumns", int.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Boolean> chartListVisible = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Boolean>(this, "chartListVisible", "chartListVisible", boolean.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key> dataBody = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key>(this, "dataBody", "dataBody", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.miyake.loveviewweb.shared.model.DataModel.DataType> dataType = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.miyake.loveviewweb.shared.model.DataModel.DataType>(this, "dataType", "dataType", com.miyake.loveviewweb.shared.model.DataModel.DataType.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key> folder = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key>(this, "folder", "folder", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel> name = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel>(this, "name", "name");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key> originalData = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key>(this, "originalData", "originalData", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key> owner = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key>(this, "owner", "owner", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Boolean> parsed = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Boolean>(this, "parsed", "parsed", boolean.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key> plugin = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key>(this, "plugin", "plugin", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key> sourceData = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.google.appengine.api.datastore.Key>(this, "sourceData", "sourceData", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.miyake.loveviewweb.shared.model.DataModel.SourceType> sourceType = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, com.miyake.loveviewweb.shared.model.DataModel.SourceType>(this, "sourceType", "sourceType", com.miyake.loveviewweb.shared.model.DataModel.SourceType.class);

    /** */
    public final org.slim3.datastore.CollectionAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.util.List<com.google.appengine.api.datastore.Key>, com.google.appengine.api.datastore.Key> valueKeys = new org.slim3.datastore.CollectionAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.util.List<com.google.appengine.api.datastore.Key>, com.google.appengine.api.datastore.Key>(this, "valueKeys", "valueKeys", java.util.List.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.DataModel, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    private static final DataModelMeta slim3_singleton = new DataModelMeta();

    /**
     * @return the singleton
     */
    public static DataModelMeta get() {
       return slim3_singleton;
    }

    /** */
    public DataModelMeta() {
        super("DataModel", com.miyake.loveviewweb.shared.model.DataModel.class);
    }

    @Override
    public com.miyake.loveviewweb.shared.model.DataModel entityToModel(com.google.appengine.api.datastore.Entity entity) {
        com.miyake.loveviewweb.shared.model.DataModel model = new com.miyake.loveviewweb.shared.model.DataModel();
        model.setChartColumns(longToPrimitiveInt((java.lang.Long) entity.getProperty("chartColumns")));
        model.setChartListVisible(booleanToPrimitiveBoolean((java.lang.Boolean) entity.getProperty("chartListVisible")));
        model.setDataBody((com.google.appengine.api.datastore.Key) entity.getProperty("dataBody"));
        model.setDataType(stringToEnum(com.miyake.loveviewweb.shared.model.DataModel.DataType.class, (java.lang.String) entity.getProperty("dataType")));
        model.setFolder((com.google.appengine.api.datastore.Key) entity.getProperty("folder"));
        model.setKey(entity.getKey());
        model.setName((java.lang.String) entity.getProperty("name"));
        model.setOriginalData((com.google.appengine.api.datastore.Key) entity.getProperty("originalData"));
        model.setOwner((com.google.appengine.api.datastore.Key) entity.getProperty("owner"));
        model.setParsed(booleanToPrimitiveBoolean((java.lang.Boolean) entity.getProperty("parsed")));
        model.setPlugin((com.google.appengine.api.datastore.Key) entity.getProperty("plugin"));
        model.setSourceData((com.google.appengine.api.datastore.Key) entity.getProperty("sourceData"));
        model.setSourceType(stringToEnum(com.miyake.loveviewweb.shared.model.DataModel.SourceType.class, (java.lang.String) entity.getProperty("sourceType")));
        model.setValueKeys(toList(com.google.appengine.api.datastore.Key.class, entity.getProperty("valueKeys")));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        com.miyake.loveviewweb.shared.model.DataModel m = (com.miyake.loveviewweb.shared.model.DataModel) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("chartColumns", m.getChartColumns());
        entity.setProperty("chartListVisible", m.isChartListVisible());
        entity.setProperty("dataBody", m.getDataBody());
        entity.setProperty("dataType", enumToString(m.getDataType()));
        entity.setProperty("folder", m.getFolder());
        entity.setProperty("name", m.getName());
        entity.setProperty("originalData", m.getOriginalData());
        entity.setProperty("owner", m.getOwner());
        entity.setProperty("parsed", m.isParsed());
        entity.setProperty("plugin", m.getPlugin());
        entity.setProperty("sourceData", m.getSourceData());
        entity.setProperty("sourceType", enumToString(m.getSourceType()));
        entity.setProperty("valueKeys", m.getValueKeys());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("slim3.schemaVersion", 1);
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        com.miyake.loveviewweb.shared.model.DataModel m = (com.miyake.loveviewweb.shared.model.DataModel) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        com.miyake.loveviewweb.shared.model.DataModel m = (com.miyake.loveviewweb.shared.model.DataModel) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        com.miyake.loveviewweb.shared.model.DataModel m = (com.miyake.loveviewweb.shared.model.DataModel) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
    }

    @Override
    protected void incrementVersion(Object model) {
        com.miyake.loveviewweb.shared.model.DataModel m = (com.miyake.loveviewweb.shared.model.DataModel) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    protected void postGet(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        com.miyake.loveviewweb.shared.model.DataModel m = (com.miyake.loveviewweb.shared.model.DataModel) model;
        writer.beginObject();
        org.slim3.datastore.json.Default encoder0 = new org.slim3.datastore.json.Default();
        writer.setNextPropertyName("chartColumns");
        encoder0.encode(writer, m.getChartColumns());
        writer.setNextPropertyName("chartListVisible");
        encoder0.encode(writer, m.isChartListVisible());
        writer.setNextPropertyName("content");
        encoder0.encode(writer, m.isContent());
        if(m.getDataBody() != null){
            writer.setNextPropertyName("dataBody");
            encoder0.encode(writer, m.getDataBody());
        }
        if(m.getDataType() != null){
            writer.setNextPropertyName("dataType");
            encoder0.encode(writer, m.getDataType());
        }
        if(m.getFolder() != null){
            writer.setNextPropertyName("folder");
            encoder0.encode(writer, m.getFolder());
        }
        if(m.getImageDataBody() != null){
            writer.setNextPropertyName("imageDataBody");
            encoder0.encode(writer, m.getImageDataBody());
        }
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder0.encode(writer, m.getKey());
        }
        if(m.getName() != null){
            writer.setNextPropertyName("name");
            encoder0.encode(writer, m.getName());
        }
        if(m.getOriginalData() != null){
            writer.setNextPropertyName("originalData");
            encoder0.encode(writer, m.getOriginalData());
        }
        if(m.getOriginalDataUrl() != null){
            writer.setNextPropertyName("originalDataUrl");
            encoder0.encode(writer, m.getOriginalDataUrl());
        }
        if(m.getOwner() != null){
            writer.setNextPropertyName("owner");
            encoder0.encode(writer, m.getOwner());
        }
        writer.setNextPropertyName("parsed");
        encoder0.encode(writer, m.isParsed());
        if(m.getPlugin() != null){
            writer.setNextPropertyName("plugin");
            encoder0.encode(writer, m.getPlugin());
        }
        if(m.getSourceData() != null){
            writer.setNextPropertyName("sourceData");
            encoder0.encode(writer, m.getSourceData());
        }
        if(m.getSourceType() != null){
            writer.setNextPropertyName("sourceType");
            encoder0.encode(writer, m.getSourceType());
        }
        if(m.getValueKeys() != null){
            writer.setNextPropertyName("valueKeys");
            writer.beginArray();
            for(com.google.appengine.api.datastore.Key v : m.getValueKeys()){
                encoder0.encode(writer, v);
            }
            writer.endArray();
        }
        if(m.getValues() != null){
            writer.setNextPropertyName("values");
            // com.miyake.loveviewweb.shared.model.ValueModel is not supported.
        }
        if(m.getVersion() != null){
            writer.setNextPropertyName("version");
            encoder0.encode(writer, m.getVersion());
        }
        if(m.getXyDataBody() != null){
            writer.setNextPropertyName("xyDataBody");
            encoder0.encode(writer, m.getXyDataBody());
        }
        writer.endObject();
    }

    @Override
    protected com.miyake.loveviewweb.shared.model.DataModel jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        com.miyake.loveviewweb.shared.model.DataModel m = new com.miyake.loveviewweb.shared.model.DataModel();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.Default decoder0 = new org.slim3.datastore.json.Default();
        reader = rootReader.newObjectReader("chartColumns");
        m.setChartColumns(decoder0.decode(reader, m.getChartColumns()));
        reader = rootReader.newObjectReader("chartListVisible");
        m.setChartListVisible(decoder0.decode(reader, m.isChartListVisible()));
        reader = rootReader.newObjectReader("content");
        m.setContent(decoder0.decode(reader, m.isContent()));
        reader = rootReader.newObjectReader("dataBody");
        m.setDataBody(decoder0.decode(reader, m.getDataBody()));
        reader = rootReader.newObjectReader("dataType");
        m.setDataType(decoder0.decode(reader, m.getDataType(), com.miyake.loveviewweb.shared.model.DataModel.DataType.class));
        reader = rootReader.newObjectReader("folder");
        m.setFolder(decoder0.decode(reader, m.getFolder()));
        reader = rootReader.newObjectReader("imageDataBody");
        m.setImageDataBody(decoder0.decode(reader, m.getImageDataBody(), com.miyake.loveviewweb.shared.model.ImageDataBodyModel.class));
        reader = rootReader.newObjectReader("key");
        m.setKey(decoder0.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("name");
        m.setName(decoder0.decode(reader, m.getName()));
        reader = rootReader.newObjectReader("originalData");
        m.setOriginalData(decoder0.decode(reader, m.getOriginalData()));
        reader = rootReader.newObjectReader("originalDataUrl");
        m.setOriginalDataUrl(decoder0.decode(reader, m.getOriginalDataUrl()));
        reader = rootReader.newObjectReader("owner");
        m.setOwner(decoder0.decode(reader, m.getOwner()));
        reader = rootReader.newObjectReader("parsed");
        m.setParsed(decoder0.decode(reader, m.isParsed()));
        reader = rootReader.newObjectReader("plugin");
        m.setPlugin(decoder0.decode(reader, m.getPlugin()));
        reader = rootReader.newObjectReader("sourceData");
        m.setSourceData(decoder0.decode(reader, m.getSourceData()));
        reader = rootReader.newObjectReader("sourceType");
        m.setSourceType(decoder0.decode(reader, m.getSourceType(), com.miyake.loveviewweb.shared.model.DataModel.SourceType.class));
        reader = rootReader.newObjectReader("valueKeys");
        {
            java.util.ArrayList<com.google.appengine.api.datastore.Key> elements = new java.util.ArrayList<com.google.appengine.api.datastore.Key>();
            org.slim3.datastore.json.JsonArrayReader r = rootReader.newArrayReader("valueKeys");
            if(r != null){
                reader = r;
                int n = r.length();
                for(int i = 0; i < n; i++){
                    r.setIndex(i);
                    com.google.appengine.api.datastore.Key v = decoder0.decode(reader, (com.google.appengine.api.datastore.Key)null)                    ;
                    if(v != null){
                        elements.add(v);
                    }
                }
                m.setValueKeys(elements);
            }
        }
        reader = rootReader.newObjectReader("values");
        reader = rootReader.newObjectReader("version");
        m.setVersion(decoder0.decode(reader, m.getVersion()));
        reader = rootReader.newObjectReader("xyDataBody");
        m.setXyDataBody(decoder0.decode(reader, m.getXyDataBody(), com.miyake.loveviewweb.shared.model.XyDataBodyModel.class));
        return m;
    }
}